package graphics.tools;

/**
 * Static data needed in the program. All dimension are of 1:100 in GeoMag
 * scale.
 * 
 * @author: Eirik Vigeland
 * @version: %I%, %G%
 */
public class ShapeData {

	/**
	 *  Sphere diameter is 12.70 millimeters
	 */
	public static final double SPHERERADIUS = (12.70d / 2.0d) / 100.0d;

	/**
	 *  Rod diameter is 7.40 millimeters
	 */
	public static final double RODRADIUS = (7.40d / 2.0d) / 100.0d;

	/**
	 *  Rod length is 27 millimeters
	 */
	public static final double RODLENGTH = 27.0d / 100.0d; 

	/**
	 *  Time to show options on click in milliseconds (10 seconds)
	 */
	public static final int TIMEOUT = 10000;

	/**
	 *  Angle of 135 degrees
	 */
	public static final double ANGLE10 = Math.PI / 36.0d;

	/**
	 *  Angle of 45 degrees
	 */
	public static final double ANGLE45 = Math.PI / 4.0d;

	/**
	 *  Angle of 90 degrees
	 */
	public static final double PERPENDICULAR = Math.PI / 2.0d;

	/**
	 *  Angle of 135 degrees
	 */
	public static final double ANGLE135 = 3.0d * Math.PI / 4.0d;

	/**
	 *  Angle of 135 degrees
	 */
	public static final double ANGLE360 = 2.0d * Math.PI;

	/**
	 *  Displacement offset of rods
	 */
	public static final double OFFSET = (RODLENGTH / 2.0d) + (SPHERERADIUS);
	
	/**
	 *  Displacement offset of rods with collision extension
	 */
	public static final double C_OFFSET = (RODLENGTH / 2.0d) + (SPHERERADIUS) + 0.0000000000000001;

	/**
	 *  Angel choices
	 */
	public static final boolean COS = true, SIN = false;

	/**
	 *  Placement of rods on a ball
	 */
	public final static int TOP = 1, BOTTOM = 2, RIGHT = 3, LEFT = 4,
			FRONT = 5, BACK = 6;
	
	/**
	 *  Rotation of rods
	 */
	public final static int ROTATE_X = 0, ROTATE_Y = 1, ROTATE_Z = 2, ROTATE_DISABLE = 3;

	/**
	 * Calculates the offset with an angle.
	 * 
	 * @param angle
	 *            The angle of the rod to
	 * @param which
	 *            Set to decide whether to calculate the near or the opposite
	 *            cathetus.
	 * @return The value of the offset.
	 */
	public static double angleOffset(double angle, boolean which) {
		if (which)
			return Math.cos(angle) * OFFSET;
		else
			return Math.sin(angle) * OFFSET;
	}
	
	/**
	 * Calculates the offset for balls with an angle and a collision differential.
	 * 
	 * @param angle
	 *            The angle of the rod to
	 * @param which
	 *            Set to decide whether to calculate the near or the opposite
	 *            cathetus.
	 * @return The value of the offset.
	 */
	public static double angleOffsetBall(double angle, boolean which) {
		if (which)
			return Math.cos(angle) * C_OFFSET;
		else
			return Math.sin(angle) * C_OFFSET;
	}
}
